<script setup lang="ts">
import { biProductLineData } from "@/views/mes/lineBi/common/commonTs";

const { getDeviceList, deviceList } = biProductLineData();
const props = defineProps({
  formData: {
    type: Object,
    default: () => ({
      deviceId: "",
      deviceName: "",
      deviceCode: "",
    }),
  },
});

const setDevice = (deviceId) => {
  const find = deviceList.value.find((item) => item.id === deviceId);
  props.formData.deviceName = find.assetName;
  props.formData.deviceCode = find.assetCode;
};

onMounted(() => {
  getDeviceList();
});
</script>

<template>
  <el-select
    style="width: 100%"
    v-model="props.formData.deviceId"
    placeholder="请选择电炉"
    clearable
    @change="setDevice"
  >
    <el-option
      v-for="item in deviceList"
      :key="item.id"
      :label="item.assetName"
      :value="item.id"
    />
  </el-select>
</template>

<style scoped lang="scss"></style>
